<?php

namespace addons\mental\controller;

use addons\mental\model\Feedback as feedbackModel;

class Feedback extends Base
{
    protected $noNeedLogin = [];

    /**
     * Undocumented function
     * 意见反馈
     * @return void
     */
    public function add()
    {
        $content = $this->request->param('content');
        if (!$content) {
            $this->error(__('Invalid parameters'));
        }
        $feedbackModel = new feedbackModel();
        $status = $feedbackModel->save([
            'user_id' => $this->auth->id,
            'content' => $content
        ]);
        if ($status) {
            $this->success(__('Operation completed'));
        }
        $this->error(__('Operation failed'));
    }

    /**
     * Undocumented function
     * 列表
     * @return void
     */
    public function get_list()
    {
        $param = $this->request->param();
        $feedbackModel = new feedbackModel();
        $list = $feedbackModel->tableList($param);
        if (!$list->total()) {
            $this->error(__('No results were found'));
        }
        $this->success(__('Operation completed'), $list);
    }
}
